<template>
  <div class="contain-report">
    <div class="report-title">通知消息</div>
    <div class="report-list" v-for="item in list" :key="item.id">
      <div class="list-box">
        <h3 style="margin-bottom: 10px">{{ item.name }}</h3>
        <span style="color: #999">{{ item.message }}</span>
      </div>
      <div class="right">
        <div class="right-date">
          <span style="margin-bottom: 10px">实验室:</span>
          <span>{{ item.laboratoryName }}</span>
        </div>
        <div class="right-content">
          <span style="margin-bottom: 10px">上传时间:</span>
          <span>{{ item.createTime }}</span>
        </div>
      </div>
    </div>
    <div class="report-page">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="1"
          :page-sizes="[5]"
          :page-size="5"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {noticeList} from "../../api/laboratory";

export default {
  data() {
    return {
      form: {
        pageIndex: 1,
        pageSize: 5
      },
      total: null,
      list: []
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    async getList() {
      const {data} = await noticeList(this.form)
      console.log(data)
      if (data.code === 200) {
        this.list = data.data.data
        this.total = data.data.total
      }
    },
    handleSizeChange(val) {
      this.form.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.form.pageIndex = val
      this.getList()
    }
  },
}
</script>

<style scoped lang="less">
.contain-report {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;

  .report-title {
    font-size: 22px;
    color: #666;
  }

  .report-search {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;

    p {
      margin: 0 10px;
      box-sizing: border-box;

      &:hover {
        cursor: pointer;
      }
    }
  }

  .report-list {
    width: 100%;
    margin: 20px 0;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 5px 0 #ccc;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .list-box {
      width: 50%;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: flex-start;
    }

    .right {
      width: 50%;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .right-content {
        width: fit-content;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-around;
        color: #999;
      }

      .right-date {
        width: 20%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-around;
        color: #999;
      }

      .btns {
        width: 60%;
        padding: 0 5%;
        box-sizing: border-box;
        display: flex;
        justify-content: center;
      }
    }

  }

  .report-page {
    position: absolute;
    bottom: 10px;
    left: 50%;
    width: 100%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>
